package com.flight.trans.adapter;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.flight.trans.R;
import com.flight.trans.activity.SeePicActivity;
import com.flight.trans.base.BaseActivity;
import com.flight.trans.base.BaseRecyclerAdapter;
import com.flight.trans.base.BaseViewHolder;
import com.flight.trans.bean.UnusualBean.UnusualData;
import com.flight.trans.global.Constant;
import com.flight.trans.global.ConstantInfo;
import com.flight.trans.util.LogUtils;
import com.flight.trans.util.ToastUtils;

import java.util.ArrayList;
import java.util.List;

/**
 *    author : King
 *    date   : 2022/1/10
 *    desc   : 进港入库交接
 */
public class UnusualListAdapter extends BaseRecyclerAdapter<UnusualData> {

    private boolean isCa ;
    private int turnType ;

    public UnusualListAdapter(Context mContext, List<UnusualData> mList , boolean isCa , int turnType) {
        super(mContext, mList);
        this.isCa = isCa ;
        this.turnType = turnType ;
    }

    @Override
    public int setContentView() {
        return R.layout.adapter_unusual_list;
    }

    @Override
    protected void bindData(BaseViewHolder holder, UnusualData data, int position) {
        LinearLayout mLlContainerItem = holder.findViewById(R.id.mLlContainerItem);
        TextView mTvUnusualType = holder.findViewById(R.id.mTvUnusualType);
        TextView mTvUnusualGradle = holder.findViewById(R.id.mTvUnusualGradle);
        TextView mTvUnusualCount = holder.findViewById(R.id.mTvUnusualCount);
        TextView mTvRemarks = holder.findViewById(R.id.mTvRemarks);
        TextView mTvCreatePerson = holder.findViewById(R.id.mTvCreatePerson);

        ImageView mIvCheckImage = holder.findViewById(R.id.mIvCheckImage);

        boolean isDelete = (turnType == 0 && ConstantInfo.UnusualIDList.contains(data.getId())) || turnType != 0 ;

        mTvUnusualType.setText(data.getTypeName());
        mTvUnusualGradle.setVisibility(isCa ? View.VISIBLE : View.GONE);
        mTvUnusualGradle.setText(TextUtils.isEmpty(data.getGrade()) ? "无" : data.getGrade());
        mTvUnusualCount.setText(String.valueOf(data.getNumber()));
        mTvRemarks.setText(data.getExplain());
        mTvCreatePerson.setText(data.getCreateName());

        mTvUnusualType.setTextColor(mContext.getColor(isDelete ? R.color.color_red : R.color.black));
        mTvUnusualGradle.setTextColor(mContext.getColor(isDelete ? R.color.color_red : R.color.black));
        mTvUnusualCount.setTextColor(mContext.getColor(isDelete ? R.color.color_red : R.color.black));
        mTvRemarks.setTextColor(mContext.getColor(isDelete ? R.color.color_red : R.color.black));
        mTvCreatePerson.setTextColor(mContext.getColor(isDelete ? R.color.color_red : R.color.black));

        setOnTextClickListener(mIvCheckImage , position);

        setItemClickListener(mLlContainerItem , position);
    }
}
